import { NgModule } from '@angular/core';
import { RouterModule, Routes }  from '@angular/router';
import { Page404Component } from './page-404/page-404.component';
import { LoggedInGuard } from './auth/loggedIn.guard';
import { LayoutComponent } from './layout/layout.component';

const routes:Routes = <Routes>[
  {
    path: 'auth',
    loadChildren: 'app/auth/auth.module#AuthModule'
  },
  {
    path: '',
    loadChildren: 'app/layout/layout.module#LayoutModule',
    canLoad: [LoggedInGuard],
  },
  {
    path: '',
    loadChildren: 'app/layout/layout.module#LayoutModule',
    canLoad: [LoggedInGuard],
    //redirectTo: '/auth',
    //pathMatch: 'prefix'
  },
  {
    path: 'test',
    loadChildren: 'app/test/test.module#TestModule'
  },
  {
    path: '**',
    component: Page404Component
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, { useHash: true })
  ],
  exports: [
    RouterModule
  ]
})
export class AppRoutingModule { }
